<title>商品属性</title>

<div class="layui-fluid">
    <table id="attribute-list" class="layui-table ex-table" lay-filter="attribute-list"></table>
</div>

<script type="text/html" id="attribute-toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm save" data-title="添加属性" data-url="/attribute/save"> 添加属性 </button>
    </div>
</script>
<!-- 操作列 -->
<script type="text/html" id="attribute-state">
    <a class="layui-btn layui-btn-primary layui-btn-xs save" data-title="编辑属性" data-url="/attribute/save" data-id='{{ d.id }}'>修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs delete" data-url="admin/attribute/delete/id/{{ d.id }}">删除</a>
</script>

<script>
    layui.extend({
		treetable: 'lay-module/treetable-lay/treetable',
	}).use(['table', 'treetable'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var treetable = layui.treetable;

        // 渲染表格
        layer.load(2);
        treetable.render({
            treeColIndex: 1,
            treeSpid: 0,
            treeIdName: 'id',
            treePidName: 'pid',
            elem: '#attribute-list',
            toolbar: '#attribute-toolbar',
            url: layui.setter.API_HOST + '/admin/attribute/index',
            page: false,
            cols: [[
                {type: 'numbers'},
                {field: 'name', width: 320, title: '属性名称'},
                {templet: '#attribute-state', title: '操作'}
            ]],
            done: function (res) {
				console.log(res);
                layer.closeAll('loading');
            }
        });
    });
</script>
